<!DOCTYPE html>
<!-- saved from url=(0029)http://my.sto.cn/Vip/RealName -->
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8;">
    <meta http-equiv="Cache-Control" content="no-siteapp">
    <title> 实名认证 </title>

    <script type="text/javascript" src="/admin/js/jquery.min.js"></script>
    <script src="/home/branch/js/idangerous.swiper.min.js"></script>


    <link rel="stylesheet" type="text/css" href="/home/userManager/css/combo.select.css">
    <link rel="stylesheet" type="text/css" href="/home/userManager/css/red.css">
    <link rel="stylesheet" type="text/css" href="/home/userManager/css/realName.css">
    <link rel="stylesheet" type="text/css" href="/home/userManager/css/common.css">
    <link rel="stylesheet" type="text/css" href="/home/layui/css/modules/layer/default/layer.css">
    <link rel="stylesheet" type="text/css" href="/home/layui/css/layui.css">

    <style>
        .combo-select {
            display: inline-block;
            width: 103px;
            height: 40px;
            border: 0px;
            margin-top: 0px;
            margin-left: 0px;
            margin-bottom: 0px;
        }

        .combo-select .combo-input {
            height: 38px;
            width: 102px;
        }

        .city-picker-dropdown {
            top: 40px;
            left: 40px;
        }
    </style>

</head>
<body>

<#include "../common/header.ftl">
<#include "../common/top_nav.ftl">
<div class="box" style="min-height:800px;">

    <div class="viewAddress">
        <div class="left">
            <div class="title">
                <span><img src="/home/userManager/images/user.png" alt="账户icon"></span>
                <span class="titleText">账户管理</span>
            </div>
            <ul>
                <li><a class="<#if active == 0>on</#if>" href="/home/userManager/index">基本信息</a></li>
                <li><a class="<#if active == 1>on</#if>" href="/home/address/list">地址中心</a></li>
                <li><a class="<#if active == 2>on</#if>" href="/home/userManager/realName">实名认证</a></li>
            </ul>
        </div>


    <#if byHomeUserId??>
        <div class="right">
            <div class="title">
                <span>根据国家邮政局最新规定，寄收快递必须实名制</span>
            </div>
            <div class="title">
                <label>您已实名成功，实名认证信息如下</label>
            </div>
            <div id="addAddress" class="addAddress">
                <p class="addPDetail">
                    <label>姓名：</label>
                    <input type="text" class="addName" name="name" id="name" maxlength="15" value="${byHomeUserId.name}"
                           readonly>
                </p>
                <p class="addaddPDetailPlong ">
                    <label>身份证号：</label>
                    <input type="text" class="addName" name="idCard" id="idCard" maxlength="15" readonly value="">
                </p>
            </div>
        </div>
    <#else>
        <div class="right">
            <div class="title">
                <span>根据国家邮政局最新规定，寄收快递必须实名制</span>
            </div>
            <form method="post" id="realNameForm">
                <div id="addAddress" class="addAddress">
                    <p class="addP ">
                        <label>姓名：</label>
                        <input type="text" class="addName" name="name" id="name" maxlength="15">
                        <label>性别：</label>
                        <select class="addName" name="sex" id="sex" tabindex="-1">
                            <option value="1">男</option>
                            <option value="2">女</option>
                        </select>
                    </p>

                    <p class="addPlong ">
                        <label>身份证号：</label>
                        <input type="text" class="addName" name="idCard" id="idCard" maxlength="18">
                    </p>
                </div>
                <div class="title">
                    <label>邮箱验证</label>
                </div>
                <div id="addAddress" class="addAddress">
                    <p class="addPlong">
                        <label>邮箱：</label>
                        <input type="text" class="addName" id="email" value="${homeUser.email!""}" readonly>
                    </p>
                    <p class="addP">
                        <label>验证码：</label>
                        <input type="text" class="addTel " name="code" id="code" maxlength="4">
                        <input class="sendCode send-code-btn" id="sendCode" type="button" value="发送验证码"
                               autocomplete="off">
                        <input class="sendCode code-btn" id="sendCode" type="button" value="重新发送"
                               autocomplete="off" style="display: none;">
                    </p>
                </div>
                <div class="submitBox">
                    <p class="submitBtn">
                        <input type="button" id="orderSubmit" value="提交">
                    </p>
                </div>
            </form>
        </div>
    </#if>
    </div>

</div>
    <#include "../common/footer.ftl"/>

<script src="/home/layer/layer.js"></script>
<script src="/home/js/msg.js"></script>
<script src="/home/layui/layui.all.js"></script>
<script src="/home/userManager/js/baseUtility.js"></script>
<script type="text/javascript" src="/home/userManager/js/jquery.combo.select.js"></script>
<script type="text/javascript" src="/home/userManager/js/common_select.js"></script>
<script>


    $(document).ready(function () {
        $('#sex').comboSelect();   // 下拉框插件 启动
        $("#orderSubmit").click(function () {
            var name = $("#name").val();
            var idCard = $("#idCard").val();
            var code = $("#code").val();

            if (name == "") {
                errorMsg("姓名不能为空");
                return false;
            }
            if (!/(^[\u4E00-\u9FA5]+$)|(^[\u4E00-\u9FA5]*·[\u4E00-\u9FA5]*$)/.test(name)) {
                errorMsg("姓名格式不正确");
                return false;
            }
            if (idCard == "") {
                errorMsg("身份证必填");
                return false;
            }
            if (!idCard.match(/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/)) {
                errorMsg("身份证号不正确");
                return false;
            }
            if (code == "") {
                errorMsg("验证码不能为空");
                return false;
            }
            layer.msg('正在实名中，请稍等', {icon: 16, shade: 0.05});
            var realNameData = $("#realNameForm").serialize();
            $.ajax({
                type: "post",
                url: "/home/userManager/addRealName",
                data: realNameData,
                success: function (data) {
                    if (data.code == 0) {
                        successMsg("实名认证成功");
                        setTimeout(function () {
                            window.location.reload();
                        }, 1000);
                    } else {
                        errorMsg(data.msg);
                    }
                }
            });
        });

        //给身份证中间16位用*显示
        <#if byHomeUserId??>
             var idCard = "${byHomeUserId.idCard}";
             var _idCard = "";
             var idCardLength = idCard.length;
             if (idCardLength > 2) {
                 var idCardLength = idCardLength - 2;
                 while (idCardLength > 0) {
                     _idCard += "*";
                     idCardLength--;
                 }
                 idCard = idCard.substr(0, 1) + _idCard + idCard.substr(idCard.length - 1, idCard.length);
                 $("#idCard").val(idCard);
             }
        </#if>
    });


    //按钮不能连续点击
    var countdown = 60;  // 时长
    function setButton() {
        $(".send-code-btn").hide();
        $(".code-btn").show();
        var timer = setInterval(function () {
            if (countdown == 0) {
                clearInterval(timer);
                $(".send-code-btn").show();
                $(".code-btn").hide();
                countdown = 60;
            }
            $(".code-btn").val('(' + (countdown - 1) + '秒)');
            countdown--;
        }, 1000);
    };

    //验证码发送
    $(".send-code-btn").click(function () {
        var email = $('#email').val();
        if (msg.isEmpty(email)) {
            errorMsg("邮箱为空");
            return;
        }
        if (!msg.isEmail(email)) {
            errorMsg("邮箱格式错误");
            return;
        }
        $.ajax({
            url: '/send_email/generate_code',
            data: {email: email, method: "ylrc_real_name_code"},
            type: 'POST',
            dataType: 'json',
            success: function (data) {
                if (data.code == 0) {
                    successMsg('发送成功注意查收!');
                    setButton();
                } else {
                    errorMsg(data.msg);
                }
            },
            error: function () {
                errorMsg("邮箱不存在");
            }
        });
    });


</script>
</body>
</html>